<template>
	<view>
		<liu-indexed-list :dataList="friendsList" @click="clickCallback"></liu-indexed-list>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				friendsList: []
			}
		},
		onShow() {
			this.queryFriendsList();
		},
		onPullDownRefresh(){
			//下拉刷新
			this.queryFriendsList();
		},
		methods: {
			// 查询好友列表
			queryFriendsList(e) {
                console.log('点击列表回调：', e)
				this.$.ajax({
					url: '/friendsRelations/queryList',
					success: (res) => {
						res.forEach((f) => {
							f.img = this.$.getImg(f.img);
						})
						this.friendsList = res;
						
						//停止下拉刷新
						uni.stopPullDownRefresh();
					}
				});
			},
			// 点击聊天事件回调方法
			clickCallback(item) {
				console.log(item);
				uni.navigateTo({
					url: '/pages/chat/chat?fid=' + item.fid + '&img=' + item.img + '&nickname=' + item.name
				})
			}
		}
	}
</script>

<style lang="scss">

</style>